<?php

namespace Biz\service\brandPack;

use Biz\model\brandPack\BrandPackageRightsLog;
use Biz\model\brandRights\BrandRightsSource;

class BrandPackageRightsLogService
{

    /**
     * 记录套餐权益变化
     * @param $packageId
     * @param $rightsId
     * @param $type
     * @param $adminId
     * @param $rightsNum
     * @param $rightsName
     * @return bool
     */
    public static function record($packageId, $rightsId, $type, $adminId, $rightsNum = 0, $rightsName = '')
    {
        if (empty($rightsName)) {
            $ret = BrandRightsSource::get('rights_name', ['id' => $rightsId]);
            if (!$ret) {
                return false;
            }
            $rightsName = $ret;
        }

        $data = [
            'package_id' => $packageId,
            'rights_id' => $rightsId,
            'rights_name' => $rightsName,
            'rights_num' => $rightsNum,
            'type' => $type,
            'admin_id' => $adminId,
        ];
        $result = BrandPackageRightsLog::insertData($data);
        if ($result) {
            return true;
        }
        return false;
    }
}